package org.takeback.chat.utils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class CheckIsInUtils {
	
	/**
	 * 判断组合是否中奖
	 * @param listNumLast
	 * @param num
	 * @return
	 */
	public static boolean isCheckIn(List<Integer> listNumLast, Integer... num) {
		System.out.println(num);
		List<Integer> listNumLastTemp = new ArrayList<Integer>();
		listNumLastTemp.addAll(listNumLast);
		List<Integer> listNum = Arrays.asList(num);
		return check(listNumLastTemp, listNum);
	}
	
	
	private static boolean check(List<Integer> listNum, List<Integer> num) {
		Iterator<Integer> sListIterator = listNum.iterator();  
		System.out.println("红包尾数是：" + listNum.toString());
		System.out.println("用户押注的方案：" + num.toString());
		while(sListIterator.hasNext()){  
		    Integer a = sListIterator.next(); //3
		    Iterator<Integer> numIterator = num.iterator();
		    while(numIterator.hasNext()){
		    	 Integer b = numIterator.next(); // 33
		    	if(a == b) {
		    		try {
						sListIterator.remove();
						numIterator.remove();
					} catch (Exception e) {
						System.out.println(e);
					}
		    	}
		    }
		} 
		if(num.size() > 0) {
			return false;
		}
		return true;
	}
	
	public static boolean checkNum(Integer... num) {
		for(Integer n : num){
			if(n == null || n < 0 || n > 9) {
				return false;
			}
		}
		return true;
	}
	

	public static void main(String[] args) {
		RedEnvelopesUtils relu = new RedEnvelopesUtils();
//		Map<String, List<Object>> redMapList = relu.getRedRandMoney();
		//组合5的判断方式
		List<Integer> imList=new ArrayList<Integer>();
		imList.add(3);
		imList.add(3);
		imList.add(2);
		imList.add(2);
		imList.add(6);
		
		List<Integer> imList2=new ArrayList<Integer>();
		imList2.add(6);
		imList2.add(3);
		imList2.add(2);
		imList2.add(3);
		imList2.add(2);
//		Collections.reverse(imList2);
		System.out.println(imList2.toString());
		System.out.println(check(imList, imList2));
		
		AtomicInteger restNumber = new AtomicInteger(5);
		int temp = restNumber.getAndDecrement();
		int temp2 = restNumber.getAndDecrement();
		System.out.println(temp2);
		Double a = 3.20;
		BigDecimal result = BigDecimal.valueOf(a).setScale(2,BigDecimal.ROUND_DOWN);
		System.out.println(result);
	}

}
